import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import enMessages from './languages/en.json';
import ruMessages from './languages/ru.json';

const resources = {
    en: {
        translation: enMessages,
    },
    ru: {
        translation: ruMessages,
    },
};

const savedLanguage = localStorage.getItem('selectedLanguage');

i18n
    .use(initReactI18next)
    .init({
        resources,
        lng: savedLanguage || 'en',
        fallbackLng: 'en',
        interpolation: {
            escapeValue: false
        },
    });

export default i18n;